#! /bin/bash

#
# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
#
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
#
# See https://cangjie-lang.cn/pages/LICENSE for license information.

project_path=$(cd `dirname $0`; pwd)




# x86_64

cd  ${project_path}/

echo start build ffi ......
mkdir -p ./target/release/hicrypto
rm -rf ./target/release/hicrypto/libffiKeys.so
gcc -I /usr/local/include/hitls/auth -I /usr/local/include/hitls/bsl -I /usr/local/include/hitls/crypto -I /usr/local/include/hitls/pki -I /usr/local/include/hitls/tls -shared -fPIC ./ffi/keys.c -o ./target/release/hicrypto/libffiKeys.so
if [ $? -ne 0 ]; then
    echo "Error: build ffi failed"
    exit 1
fi
echo build ffi success



echo start build HiCrypto ......
cjpm build -V
if [ $? -ne 0 ]; then
    echo "Error: build HiCrypto failed"
    exit 1
fi
echo build HiCrypto success
